package com.itshops.service.impl;

import com.itshops.dao.ProductDao;
import com.itshops.dao.impl.ProductDaoImpl;
import com.itshops.entity.PageBean;
import com.itshops.entity.Product;
import com.itshops.service.ProductService;

import java.sql.SQLException;
import java.util.List;

public class ProductServiceImpl implements ProductService {
    ProductDao productDao=new ProductDaoImpl();
    @Override
    public PageBean<Product> findPage(String tId, int page, int pagesize) throws SQLException {

        //查询总条数
       long count =productDao.selectCountBytId(tId);

       //查询当前页对应的商品
        List<Product> list=productDao.selectProductByPage(page,pagesize,tId);

        return new PageBean<Product>(list,page,pagesize,count);
    }

    @Override
    public Product fiandProductByPid(String pId) throws SQLException {
        //id对应的商品
        Product product=productDao.selectProductByPid(pId);
        return product;
    }
}
